package likou.bisai._20210516;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/05/16 10:31
 */
public class _1 {
    public static void main(String[] args) {
        System.out.println(subsetXORSum(new int[]{5,1,6}));
        System.out.println(list);
    }
    static int res = 0;
    static List<Integer> list = new ArrayList<>();

    public static int subsetXORSum(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            dfs(nums, 0, i);
        }
        return res;
    }

    public static void dfs(int[] nums, int now, int index) {
        if (index==nums.length){
            return;
        }
        list.add(now ^ nums[index]);
        res += now ^ nums[index];
        for (int i = index + 1; i < nums.length; i++) {
            dfs(nums, now ^ nums[index], i);
        }
    }
}
